/**
 * Created by jaliu on 2014/11/5.
 */

/**
 * 数据的初始化
 */
var async = require('async');
//var hobby = mongoose.model('masterData_Hobbies');
var regions = mongoose.model('masterData_Regions');
var community = mongoose.model('community');
var dataDictionary = mongoose.model('masterData_Dictionaries');
var userPortrait = mongoose.model('masterData_UserPortrait');
var appHomeModules = mongoose.model('system_appHomeModules');
var user = mongoose.model('user');
var action = mongoose.model('masterData_actions');
var roleAction = mongoose.model('masterData_roleActions');
var ugcIndex = mongoose.model('system_ugcIndex');
var question = mongoose.model('question');
var neighbourActivity = mongoose.model('activity_neighbour');

action.count(function (err, count) {
    if (count == 0) {
        var data = [
            {
                name: '发布',
                tag: 'authPostQuestion'
            },
            {
                name: '问题详情的回复/评论',
                tag: 'authReplyQuestion'
            },
            {
                name: '问题详情赞',
                tag: 'authQADetailPraise'
            },
            {
                name: '问题详情举报',
                tag: 'authQADetailReport'
            },
            {
                name: '群聊大厅',
                tag: 'authChatGroup'
            },
            {
                name: '个人页的私聊',
                tag: 'authChatPerson'
            },
            {
                name: '专题回复',
                tag: 'authReplyTopic'
            },
            {
                name: '首页banner活动',
                tag: 'authBanner'
            }
        ];

        data.forEach(function (temp) {
            var a = new action();
            a.name = temp.name;
            a.tag = temp.tag;
            a.save(function (err, result) {
                var b = new roleAction();
                b.action = result._id;
                b.role = 'vip';
                b.save();
            });
        })
    }
});
